<template>
  <d2-container>
    <div class="app-container">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="现货信息" name="first">
          <v-spotInformation ref="child1" class="is-active"></v-spotInformation>
        </el-tab-pane>
        <el-tab-pane label="价格项" name="second">
          <v-priceItem ref="child2"></v-priceItem>
        </el-tab-pane>
      </el-tabs>
    </div>
  </d2-container>
</template>
<script>
import spotInformation from "./componnets/merchandise_news/spotInformation.vue";
import priceItem from "./componnets/merchandise_news/priceItem.vue";
export default {
  //商品信息
  components: {
    "v-spotInformation": spotInformation,
    "v-priceItem": priceItem
  },
  data() {
    return {
      activeName: "first",
      spotInformation,
      priceItem
    };
  },
  methods: {
    updateType() {
      let activeTab = this.$route.query.table;
      // 判断type的值，更改activeName的值
      if (activeTab === "first") {
        this.activeName = "first";
      } else if (activeTab === "second") {
        this.activeName = "second";
      }
    },
    handleClick(tab, event) {
      console.log(tab, event);
    }
  },
  mounted() {
    this.updateType();
  }
};
</script>
